package builder;

/**
 * @author zhangxi
 * @date 2021/10/11
 */
public class Product {

    private String field1;
    private String field2;
    private String field3;

    public String getField1() {
        return field1;
    }

    public void setField1(String field1) {
        this.field1 = field1;
    }

    public String getField2() {
        return field2;
    }

    public void setField2(String field2) {
        this.field2 = field2;
    }

    public String getField3() {
        return field3;
    }

    public void setField3(String field3) {
        this.field3 = field3;
    }

    @Override
    public String toString() {
        return "Product{" +
                "field1='" + field1 + '\'' +
                ", field2='" + field2 + '\'' +
                ", field3='" + field3 + '\'' +
                '}';
    }

    private Product(ProductBuilder productBuilder) {
        this.field1 = productBuilder.field1;
        this.field2 = productBuilder.field2;
        this.field3 = productBuilder.field3;
    }

    public static class ProductBuilder{
        private String field1;
        private String field2;
        private String field3;

        public ProductBuilder field1(String field1){
            this.field1 = field1;
            return this;
        }

        public ProductBuilder field2(String field2){
            this.field2 = field2;
            return this;
        }

        public ProductBuilder field3(String field3){
            this.field3 = field3;
            return this;
        }

        public Product build (){
            return new Product(this);
        }

    }
}
